#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int g[N][N];
int n, m;
int st, ed;
int state[N];
int cnt;
int d[N];
void dfs(int u)
{
	if (u == ed) {
		cnt++;
		for (int i = 1; i <= n; i++) {
			if (state[i]) {
				d[i]++;
			}
		}
		return;
	}
	for (int i = 1; i <= n; i++) {
		if (g[u][i] && !state[i]) {
			state[i] = 1;
			dfs(i);
			state[i] = 0;
		}
	}
}
int main()
{
	cin >> n >> m;
	while (m--) {
		int a, b;
		cin >> a >> b;
		g[a][b] = g[b][a] = 1;
	}
	cin >> st >> ed;
	state[st] = 1;
	dfs(st);
	if (!cnt) {
		cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i != st && i != ed) {
			if (d[i] == cnt)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}